package com.jh.user.pojo.freeQuick;

import java.util.Objects;

import static com.google.common.base.Strings.isNullOrEmpty;

/**
 * @author Yichuan
 * @version 1.0
 */
public enum ChannelCode {

    /**
     * 畅捷代还04
     */
    PAY_CHAN_CODE04("pay.chan.code04", "\u7545\u6377\u4ee3\u8fd804", "CHANPAYNEWCARD_04", true),

    /**
     * 畅捷代还0101
     */
    PAY_CHAN_CODE0101("pay.chan.code0101", "\u7545\u6377\u4ee3\u8fd80101", "CHANPAYNEWCARD_0101", true),

    /**
     * 畅捷代还0102
     */
    PAY_CHAN_CODE0102("pay.chan.code0102", "\u7545\u6377\u4ee3\u8fd80102", "CHANPAYNEWCARD_0102", true)
    ;

    private final String value;
    private final String desc;
    private final String code;
    private final boolean enroll;

    ChannelCode(String value, String desc, String code, boolean enroll) {
        this.value = value;
        this.desc = desc;
        this.code = code;
        this.enroll = enroll;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public String getCode() {
        return code;
    }

    public boolean isEnroll() {
        return enroll;
    }

    public static ChannelCode of(String value) {
        if (isNullOrEmpty(value)) {
            return null;
        }
        for (ChannelCode scc: values()) {
            if (Objects.equals(scc.getValue(), value)) {
                return scc;
            }
        }
        return null;
    }

    public static ChannelCode code(String code) {
        if (isNullOrEmpty(code)) {
            return null;
        }
        for (ChannelCode scc: values()) {
            if (Objects.equals(scc.getCode(), code)) {
                return scc;
            }
        }
        return null;
    }
}
